import request from '@/config/axios'

export interface RoomRentVo {
  id: number
  commId: number
  houseId: number
  roomId: number
  rentAddrName: string
  rentUserId: number
  rentUserName: string
}

// 创建租客管理
export const createRoomRent = async (data: RoomRentVo) => {
  return await request.post({
    url: '/zwsj/room-rent/create',
    data: data
  })
}

export interface RoomRentBeforeUpdateVo {
  oldRoomId: number
  newRoomId: number
}
// 更换地址之前验证
export const beforeReplaceRentRoomCheck = async (params: RoomRentBeforeUpdateVo) => {
  return await request.get({
    url: '/zwsj/room-rent/before/replace/room/check',
    params: params
  })
}

// 更新租客管理
export const replaceRoom = async (data: RoomRentVo) => {
  return await request.put({
    url: '/zwsj/room-rent/replace/room',
    data: data
  })
}

// 删除租客管理
export const deleteRoomRent = async (id: number) => {
  return await request.delete({
    url: '/zwsj/room-rent/delete?id=' + id
  })
}

// 获得租客管理
export const getRoomRent = async (id: number) => {
  return await request.get({
    url: '/zwsj/room-rent/get?id=' + id
  })
}

// 获得租客管理分页
export const getRoomRentPage = async (params: any) => {
  return await request.get({
    url: '/zwsj/room-rent/page',
    params: params
  })
}

// 获得租客租住历史分页
export const getRoomHistoryRentPage = async (params: any) => {
  return await request.get({
    url: '/zwsj/room-rent/history/page',
    params: params
  })
}

// 导出租客管理 Excel
export const exportRoomRentExcelt = async (params: any) => {
  return await request.get({
    url: '/zwsj/room-rent/export-excel',
    params: params,
    responseType: 'blob'
  })
}
